#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <errno.h>

#include "../common/logger.h"

/*
Aside from the absence of error checking and various variable and structure
declarations, what is the problem with the following program?
 */

/*
ans. the thread continues to work on main threads stack with
unpredictible result
 */

pthread_t thread;

struct some_struct {
        int some_variable;
};

static void *thread_func(void *arg)
{
        struct some_struct *some = (struct some_struct *)arg;
        puts("inside thread_func");
}

int main(void)
{
        struct some_struct some_struct;
        pthread_create(&thread, NULL, thread_func, &some_struct);

        puts("calling pthread_exit");
        pthread_exit(NULL);

        puts("exit main");
        return EXIT_SUCCESS;
}
